#!/usr/bin/sh

# If we are running on Linux we re-compile the utilities since
# the package might be running on a different architecture
# or be running on 32 rather than 64 bit.

if [ `uname` = Linux ]
then
	cd /opt/truecl/utils
	chmod +x make
	sh ./make

	r=$?
	if [ $r != 0 ]
	then
		echo "Error: Failed to compile utilities inn /opt/truecl/utils." >&2
		exit 1
	fi

	# Now the main utilities have been made, look at compilation 
	# of the Perl/C interfaces.

	cd /opt/truecl/utils/perl_interfaces/miitoollib
	perl Makefile.PL
	r=$?
	if [ $r != 0 ]
	then
		echo "Error: Unable to make 'miitoollib' make file." >&2
		exit 1
	fi
	make
	r=$?
	if [ $r != 0 ]
	then
		echo "Error: Unable to make 'miitoollib' tool." >&2
		exit 1
	fi
	make install
	r=$?
	if [ $r != 0 ]
	then
		echo "Error: Unable to install 'miitoollib' tool." >&2
		exit 1
	fi
fi

exit 0
